feat(tools): ToolExecutor registry, mock, and native tools (issue #18)#52
Merged
Conversation
Add ToolExecutor, ToolCallRequest/Response (output + meta §13.2), ParseUses for tool.<name>.<operation>, Registry dispatching native and mock tool types, MockExecutor, and native echo/identity operations. Unknown native operations return *UnknownOperationError for structured handling (issue #18). Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the ToolExecutor boundary from design doc §12.2 G with a registry that parses workflow
usesstrings (tool.<name>.<operation>), a mock executor for tests, and native built-ins (echo,identity). Responses follow §13.2 (outputmap +metawithdurationMs/costUsdplaceholders).API
Types (
types.go)ToolExecutor—Call(ctx, ToolCallRequest) (ToolCallResponse, error)ToolCallRequest—Uses,With map[string]anyToolCallResponse—Output map[string]any,Meta ToolCallMetaRegistry (
registry.go)ParseUses("tool.github.pull_request.get")→github,pull_request.getNewRegistry(graph)— looks upgraph.Tools[name]and routes byToolSpec.Type:native→internal/tools/nativeregistry (echo,identity)mock→ optionalRegistry.MockToolExecutor, else canned JSON{"message":"mock",...}Native (
native/registry.go)echo— returns{"echo": <shallow copy of with>}identity— returns{"value": with["value"], "ok": <present>}Errors (
errors.go)*UnknownOperationError—Tool,Operationfields; returned when a native tool does not implement the operation (errors.As-friendly)Mock (
mock.go)MockExecutor— fixedResp/Error customFnNormalize (
normalize.go)Output; fillsDurationMsfrom wall clock if still zeroTests
tool.demo.echowith payload round-trips underoutput.echotool.demo.no_such_op→errors.As(..., *UnknownOperationError)with correct tool/operationParseUsesdesign-doc style path;MockExecutorisolationVerification
make fmt(go fmt ./...)make test(go test ./... -race)make vetCloses #18
Made with Cursor